package com.haidao.admin.component.web.controller;

import com.haidao.admin.component.entity.UserOperation;
import com.haidao.admin.component.params.UserOperationParam;
import com.haidao.admin.component.resp.PageResult;
import com.haidao.admin.component.service.UserOperationService;
import com.haidao.admin.core.result.Resp;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userAuditLog")
@RequiredArgsConstructor

public class UserAuditLogController {

    private final UserOperationService userOperationService;

    /**
     * 上报用户操作日志
     * @return 操作返回结果
     */
    @PostMapping("record")
    public Resp<String> userOperation(@Validated @RequestBody UserOperation userOperation ){
        userOperationService.save(userOperation);
        return Resp.ok("0");
    }

    @GetMapping("list")
    public Resp<Page<UserOperation>> list(UserOperationParam param){
        Page page=userOperationService.list(param);
        return Resp.ok(page);
    }

}
